package swingtest;

import java.awt.*;
import java.awt.event.ActionListener;
import javax.swing.*;

/**
 *
 * @author patrick
 */
public class MainWindow extends JFrame {

    public MainWindow() {
        this.addComponents();
        this.showFrame();
    }
    
    protected void addComponents() {
        //menu bar
        JMenuBar menuBar = new JMenuBar();
        menuBar.setPreferredSize(new Dimension(500, 20));
        this.setJMenuBar(menuBar);
        
        //file menu
        JMenu menu = new JMenu("File");
        menuBar.add(menu);
        
        //about button
        JMenuItem about = new JMenuItem("About");
        about.addActionListener(new AboutListener());
        menuBar.add(about);
        
        //exit menu item
        JMenuItem exit = new JMenuItem("Exit");
        exit.addActionListener(new ExitListener());
        menu.add(exit);
        
        
        //panel
        JPanel contentPane = new JPanel();       
        this.setContentPane(contentPane);
        
        //content
        contentPane.add(new JLabel("Hallo du kleiner dicker Fuchs :P"));
        contentPane.add(new JButton("Test"));
    }
    
    protected final void showFrame() {
        //parameters
        this.setTitle("Swing Test Programm");
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        
        //show
        this.pack();
        this.setVisible(true);
    }
    
    
    
}